#include "DirectDeclarator.h"
#include "../../symtab/symtab.h"
#include "Declarator.h"
#include "TypeQualifierList.h"
#include "../Expressions/ConstantExpr.h"
#include "ParameterTypeList.h"
#include "IdentifierList.h"
#include "../Expressions/AssignmentExpr.h"


DirectDeclarator::~DirectDeclarator(void)
{
	switch(m_iType)
	{
	case identifier:
		delete m_pIdentifier;
		break;
	case declarator:
		delete m_pDecl;
		break;
	case declare_arry:
		if(m_pTQualList)
			delete m_pTQualList;
		if(m_pAssignExpr)
			delete m_pAssignExpr;
		delete m_pDeclarator;
		break;
	case func_with_param:
		if(m_pParams)
			delete m_pParams;
		delete m_pDeclarator;
		break;
	case func_with_identifier:
		if(m_pIdList)
			delete m_pIdList;
		delete m_pDeclarator;
		break;
	default:
		assert(0);
	}
}

void DirectDeclarator::codeGen()
{
	COUT
	switch(m_iType)
	{
	case identifier:
		std::cout<<"identifier"<<std::endl;
		break;
	case declarator:
		m_pDecl->codeGen();
		break;
	case declare_arry:
		if(m_pTQualList)
			m_pTQualList->codeGen();
		if(m_pAssignExpr)
			m_pAssignExpr->codeGen();
		m_pDeclarator->codeGen();
		break;
	case func_with_param:
		if(m_pParams)
			m_pParams->codeGen();
		m_pDeclarator->codeGen();
		break;
	case func_with_identifier:
		if(m_pIdList)
			m_pIdList->codeGen();
		m_pDeclarator->codeGen();
		break;
	default:
		assert(0);
	}
}